<?php
include 'secure/core.php';
include 'header.php';
include 'left.php';
$fileid = mysql_real_escape_string($_GET['file']); 
$username = $files->getUploadersID($fileid);
if(isset($fileid) and $files->FileExists($fileid)){
	$now = date("Y-m-d H:i:s");
	$country_iso = $users->countryFromIP($_SERVER['REMOTE_ADDR']);
	$ref = $files->getUploadersID($fileid);
	$rand = rand(1,1000000);
	$sql_start = "insert into conversions set ip = '$_SERVER[REMOTE_ADDR]', user_id='$ref', date='$now', file_id='$fileid', rand='$rand'";
	$ado->exec($sql_start);
	$sql_start1 = "insert into file_visits set ip_address = '$_SERVER[REMOTE_ADDR]', file_id='$fileid', country_iso='$country_iso'";
	$ado->exec($sql_start1);
	$start_id = $ado->id();
}
$sql = "SELECT * FROM `gateway`";          
$res = $ado->exec($sql);
$row_array = mysql_fetch_assoc($res);
?>
<script type="text/javascript" src="js/ajax.js"></script>  
<?php if($gateway->getNetwork() == '1'){ ?>
<script type="text/javascript" src="http://www.cpalead.com/show_cu.js?pub=<?php echo $row_array['publisher_id']; ?>&subid=<?php echo $rand;?>n<?php echo $start_id; ?>"></script>
<?php } ?>
<?php if($gateway->getNetwork() == '2'){ ?>
<script src="http://adscendmedia.com/gwjs.php?aff=<?php echo $row_array['publisher_id']; ?>&prf=<?php echo $row_array['gateway_id']; ?>&sid=<?php echo $rand;?>n<?php echo $start_id; ?>" type="text/javascript"></script>
<?php } ?>
<?php if($gateway->getNetwork() == '3'){ ?>
<script src="http://www.adworkmedia.com/gLoader.php?GID=<?php echo $gateway->getGatewayID(); ?>&pubID=<?php echo $row_array['publisher_id']; ?>
&go=&sid=<?php echo $rand;?>n<?php echo $start_id; ?>" type="text/javascript"></script>
<?php } ?>  	
							
		<div id="right">
			<div class="plain">
			<?php if(isset($fileid) and $files->FileExists($fileid)){?>
				<h1><center>Download File : <?php echo $files->getFileName($fileid);?></center></h1>
				
				<h2>File Statistics</h2>
				<p><table cellspacing="0" cellpadding="0" border="0"> 
							<thead> 
								<tr>
									<th>Filename</th>
									<th>Downloads</th>
									<th>Uploaded By</th>
								</tr>
							</thead>
							<tbody>
							<tr>
							  <td><?php echo $files->getFileName($fileid);?></td>
							  <td>This file has been downloaded <?php echo $files->getUsersFileDownloads($fileid);?> times</td>
							  <td><?php echo $files->getUploadersUsername($username); ?> (#<?php echo $files->getUploadersID($fileid); ?>)</td>
							 </tr>
				  </tbody>
						</table></p>
			<?php } ?>
			</div>
			<div class="noboxcenter">
			<?php if($gateway->getNetwork() == '1'){ ?>
			<a href="javascript:startGateway('<?php echo $gateway->getGatewayID(); ?>');"><img src="gfx/icons/big/red_download_button.jpg"/></a>
			<?php } ?>
			<?php if($gateway->getNetwork() == '2'){ ?>
			<a href="javascript:initGateway(); checkIfPostBacked('<?php echo $start_id; ?>');"><img src="gfx/icons/big/red_download_button.jpg"/></a>
			<?php } ?>
			<?php if($gateway->getNetwork() == '3'){ ?>
			<a href="#" onClick="javascript:gLoad_<?php echo $gateway->getGatewayID(); ?>(); return false;"><img src="gfx/icons/big/red_download_button.jpg"/></a>
			<?php } ?>
			</div>
		</div>
<?php include 'footer.php'; ?>